*05a_results_short_het.do

capture log close

global root =  "/disk/bulkw/nencka/schooling_pandemic/2021_10_18_final/"
global input   "$root/Input"
global scripts "$root/Scripts"
global output  "$root/Output"
global temp    "$root/Temp"
global log     "$root/Log"
global figures "$root/Figures"

set scheme plotplain



*****************************************************************************
*****************************************************************************
*****************************************************************************


log using "$log/05a_results_short_het", replace text

use "$temp/analysis_data_shortrun.dta", clear

	su days_closed, de 

	tab age_at_census census_year
	cap drop age_bin

	gen age_bin = 1 if inrange(age_at_census,0,5)
	replace age_bin = 2 if inrange(age_at_census,6,10)
	replace age_bin = 3 if inrange(age_at_census,11,14)
	replace age_bin = 4 if inrange(age_at_census,15,18)
	replace age_bin = 5 if inrange(age_at_census,19,21)
	replace age_bin = 6 if inrange(age_at_census,22,25)
	

	tab age_bin, mi 

	*Create Census region indicators

	gen region = 1 if inlist(statefip, 9, 23, 25, 33, 44, 50, 34, 36, 42)
	replace region = 2 if inlist(statefip, 17, 18, 26, 39, 55, 19, 20, 27, 29, 31, 38, 46)
	replace region = 3 if inlist(statefip, 10, 11, 12, 13, 24, 37, 45, 51, 54, 1, 21, 28, 47, 5, 22, 40, 48)
	replace region = 4 if inlist(statefip, 4, 8, 16, 30, 32, 35, 49, 56, 2, 6, 15, 41, 53)


	*Generate heterogenity variables

		*Top occupation dad
		gen top_dad_occupation = 1 if occscore_f > 25 & ~mi(occscore_f)
		replace top_dad_occupation = 0 if occscore_f <= 25  & ~mi(occscore_f)

		*Assign birthplace (via https://usa.ipums.org/usa-action/variables/BPL#codes_section)
		gen dad_foreign = 1 if fbpl > 13000 & fbpl < 90000  & ~mi(fbpl)
		replace dad_foreign = 0 if mi(dad_foreign) & ~mi(fbpl)

		tab top_dad_occupation dad_foreign, mi

		*Generate race variable
		capture drop black
		gen black = 1 if inlist(race,200,210)
		replace black = 0 if mi(black)
		tab race black, m
	
	gen weeks_closed_3wks = days_closed/21
	su weeks_closed_3wks days_closed, de 


*****************************************************************************
*****************************************************************************
*****************************************************************************


*Include all 1910 city characteristic controls (interacted with birth year)
*	in the short-run specifications and focus on regressions with
*	birth year, state-by-birth year, and region-by-birth year fixed effects

tab race, m
tab mcd_c, m
desc, fullnames

local ind_covs "race##i.birthyr race##sex##mcd_c"
local city_by_covs "c.in_school_6_10_avg##i.birthyr c.in_school_11_14_avg##i.birthyr c.in_school_15_18_avg##i.birthyr c.occscore_base_avg##i.birthyr c.foreignb_avg##i.birthyr c.count##i.birthyr"



*Father's occupational score split

	reghdfe in_school ib1.age_bin##c.weeks_closed_3wks if census_year == 1920 & top_dad_occupation==1, absorb(region##birthyr `ind_covs' `city_by_covs')  cluster(mcd_c)
	parmest, format(estimate min95 max95) level(95) saving("$temp/heterogeneous_focchigh", replace) 

	reghdfe in_school ib1.age_bin##c.weeks_closed_3wks if census_year == 1920 & top_dad_occupation==0, absorb(region##birthyr `ind_covs' `city_by_covs')  cluster(mcd_c)
	parmest, format(estimate min95 max95) level(95) saving("$temp/heterogeneous_focclow", replace) 


*Father's birthplace split

	reghdfe in_school ib1.age_bin##c.weeks_closed_3wks if census_year == 1920 & dad_foreign==1, absorb(region##birthyr `ind_covs' `city_by_covs')  cluster(mcd_c)
	parmest, format(estimate min95 max95) level(95) saving("$temp/heterogeneous_fbornfor", replace) 

	reghdfe in_school ib1.age_bin##c.weeks_closed_3wks if census_year == 1920 & dad_foreign==0, absorb(region##birthyr `ind_covs' `city_by_covs')  cluster(mcd_c)
	parmest, format(estimate min95 max95) level(95) saving("$temp/heterogeneous_fbornus", replace) 


*Sex split

	reghdfe in_school ib1.age_bin##c.weeks_closed_3wks if census_year == 1920 & sex==1, absorb(region##birthyr `ind_covs' `city_by_covs')  cluster(mcd_c)
	parmest, format(estimate min95 max95) level(95) saving("$temp/heterogeneous_men", replace) 

	reghdfe in_school ib1.age_bin##c.weeks_closed_3wks if census_year == 1920 & sex==2, absorb(region##birthyr `ind_covs' `city_by_covs')  cluster(mcd_c)
	parmest, format(estimate min95 max95) level(95) saving("$temp/heterogeneous_women", replace) 


*Race split

	reghdfe in_school ib1.age_bin##c.weeks_closed_3wks if census_year == 1920 & black==1, absorb(region##birthyr `ind_covs' `city_by_covs')  cluster(mcd_c)
	parmest, format(estimate min95 max95) level(95) saving("$temp/heterogeneous_black", replace) 

	reghdfe in_school ib1.age_bin##c.weeks_closed_3wks if census_year == 1920 & black==0, absorb(region##birthyr `ind_covs' `city_by_covs')  cluster(mcd_c)
	parmest, format(estimate min95 max95) level(95) saving("$temp/heterogeneous_nonblack", replace) 




log close

